/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.admanager.piadladmanagement.plugin.piadladmanagement.impl;

import java.util.Collection;

import org.admanager.piadladmanagement.plugin.piadladmanagement.PConnectorRole;
import org.admanager.piadladmanagement.plugin.piadladmanagement.PiadladmanagementPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>PConnector Role</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.PConnectorRoleImpl#getDelegatedRoles <em>Delegated Roles</em>}</li>
 *   <li>{@link org.admanager.piadladmanagement.plugin.piadladmanagement.impl.PConnectorRoleImpl#isIsInput <em>Is Input</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PConnectorRoleImpl extends PSimpleElementImpl implements PConnectorRole {
	/**
	 * The cached value of the '{@link #getDelegatedRoles() <em>Delegated Roles</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDelegatedRoles()
	 * @generated
	 * @ordered
	 */
	protected EList delegatedRoles;

	/**
	 * The default value of the '{@link #isIsInput() <em>Is Input</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsInput()
	 * @generated
	 * @ordered
	 */
	protected static final boolean IS_INPUT_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isIsInput() <em>Is Input</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isIsInput()
	 * @generated
	 * @ordered
	 */
	protected boolean isInput = IS_INPUT_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PConnectorRoleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return PiadladmanagementPackage.Literals.PCONNECTOR_ROLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getDelegatedRoles() {
		if (delegatedRoles == null) {
			delegatedRoles = new EObjectResolvingEList(PConnectorRole.class, this, PiadladmanagementPackage.PCONNECTOR_ROLE__DELEGATED_ROLES);
		}
		return delegatedRoles;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isIsInput() {
		return isInput;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIsInput(boolean newIsInput) {
		boolean oldIsInput = isInput;
		isInput = newIsInput;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PiadladmanagementPackage.PCONNECTOR_ROLE__IS_INPUT, oldIsInput, isInput));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PiadladmanagementPackage.PCONNECTOR_ROLE__DELEGATED_ROLES:
				return getDelegatedRoles();
			case PiadladmanagementPackage.PCONNECTOR_ROLE__IS_INPUT:
				return isIsInput() ? Boolean.TRUE : Boolean.FALSE;
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PiadladmanagementPackage.PCONNECTOR_ROLE__DELEGATED_ROLES:
				getDelegatedRoles().clear();
				getDelegatedRoles().addAll((Collection)newValue);
				return;
			case PiadladmanagementPackage.PCONNECTOR_ROLE__IS_INPUT:
				setIsInput(((Boolean)newValue).booleanValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case PiadladmanagementPackage.PCONNECTOR_ROLE__DELEGATED_ROLES:
				getDelegatedRoles().clear();
				return;
			case PiadladmanagementPackage.PCONNECTOR_ROLE__IS_INPUT:
				setIsInput(IS_INPUT_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PiadladmanagementPackage.PCONNECTOR_ROLE__DELEGATED_ROLES:
				return delegatedRoles != null && !delegatedRoles.isEmpty();
			case PiadladmanagementPackage.PCONNECTOR_ROLE__IS_INPUT:
				return isInput != IS_INPUT_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (isInput: ");
		result.append(isInput);
		result.append(')');
		return result.toString();
	}

} //PConnectorRoleImpl
